// $Id: util.h,v 1.1.1.1 2012/02/17 03:45:26 hzheng Exp $

#ifndef EVCPE_UTIL_H_
#define EVCPE_UTIL_H_

#include <event.h>

#include "evcpe-internal.h"

int evcpe_is_ipaddr(const char *address);

int evcpe_is_num(const char *str);

int evcpe_add_buffer(struct evbuffer *buffer, const char *fmt, ...) EVCPE_CHKFMT(2,3);

int evcpe_encode_base64(struct evbuffer *buffer, u_char *data, unsigned len);

int evcpe_strcmp(const char *a, unsigned alen, const char *b, unsigned blen);

inline int evcpe_strncmp(const char *a, const char *b, unsigned blen);
int evcpe_bool2int(const char *text, unsigned len);

int evcpe_atol(const char *text, unsigned len, long *value);

int evcpe_atou(const char *text, unsigned len, unsigned int *value);

int evcpe_encode_base64(struct evbuffer *buffer, u_char *data, unsigned len);

int evcpe_decode_base64(struct evbuffer *buffer, unsigned *len, 
		u_char **data_start, unsigned * out_len);

char *evcpe_ltoa(long value);

int evcpe_strdup(const char *string, unsigned len, char **ptr);

#endif /* EVCPE_UTIL_H_ */

